package com.gjsh.c_arr;

public class Demo01 {
    public static void main(String[] args) {
//        冒泡排序
        int[] arr = {1, 5, 6, 4, 7, 2, 9, 3, 8};

        for (int j = 0; j < arr.length - 1; j++) {
            for (int i = 0; i < arr.length - 1 - j; i++) {
                if (arr[i] > arr[i + 1]) {
                    int temp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = temp;
                }
            }
        }

        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}
